// src/main/java/com/chixing/mapper/MessageMapper.java
package com.chixing.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chixing.entity.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<Message> {
    @Select("SELECT content FROM message WHERE user_id = #{userId} AND status = 0")
    List<String> getUnreadMessages(Long userId);

    @Update("UPDATE message SET status = 1 WHERE user_id = #{userId} AND status = 0")
    void markMessagesAsRead(Long userId);

}

